package com.wanmait.employment.manageController;

import com.github.pagehelper.PageInfo;
import com.wanmait.employment.entity.WelfareLabelBasics;
import com.wanmait.employment.service.WelfareLabelBasicsService;
import com.wanmait.employment.util.AjaxResult;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("manage/WelfareLabelBasics")
public class WelfareLabelBasicsController {

    @Resource
    private WelfareLabelBasicsService welfareLabelBasicsService;
    @GetMapping("list")
    public AjaxResult list(String title,Integer pageNum,Integer pageSize){
        PageInfo<WelfareLabelBasics> pageInfo= welfareLabelBasicsService.selectList(title,pageNum,pageSize);
        return AjaxResult.success("",pageInfo);
    }

    @PostMapping("update")
    public AjaxResult update(@RequestBody WelfareLabelBasics welfareLabelBasics){
        if(welfareLabelBasics.getId()!=null){
            welfareLabelBasicsService.update(welfareLabelBasics);
            return AjaxResult.success("");
        }
        Boolean b=welfareLabelBasicsService.insert(welfareLabelBasics);
        if(b){
            return AjaxResult.success("");
        }
        return AjaxResult.error("该标签已存在！");
    }
    @GetMapping("delete")
    public AjaxResult delete(Integer id){
        welfareLabelBasicsService.delete(id);
        return AjaxResult.success("");
    }
}
